//
//  NetworkManager.h
//  jinwan
//
//  Created by 王尧 on 2017/5/26.
//  Copyright © 2017年 wy. All rights reserved.
//

#import <Foundation/Foundation.h>
UIKIT_EXTERN NSString *const kNetResponse_M0008_3
;
/** 登录成功的状态*/
UIKIT_EXTERN NSString *const kNetResponse_R0001;
/** 账号锁定*/
UIKIT_EXTERN NSString *const kNetResponse_R0003;
/** token失效需要登录*/
UIKIT_EXTERN NSString *const kNetResponse_E0001;


@interface NetworkManager : NSObject

+ (instancetype)defaultManager;

/**
 *  发送get请求
 *
 *  @param URLString  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 */
- (void)getWithURLString:(NSString *)URLString
              parameters:(id)parameters
                 success:(void (^)(id responseObject))success
                 failure:(void (^)(NSError *error))failure;

/**
 *  发送post请求
 *
 *  @param URLString  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 */
- (void)postWithURLString:(NSString *)URLString
               parameters:(id)parameters
                  success:(void (^)(id responseObject))success
                  failure:(void (^)(NSError *error))failure;
/**
 *  发送get请求
 *
 *  @param URLString  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 */
- (void)check_getWithURLString:(NSString *)URLString
              parameters:(id)parameters
                 success:(void (^)(id responseObject))success
                 failure:(void (^)(NSError *error))failure;

/**
 *  发送post请求
 *
 *  @param URLString  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 */
- (void)check_postWithURLString:(NSString *)URLString
               parameters:(id)parameters
                  success:(void (^)(id responseObject))success
                  failure:(void (^)(NSError *error))failure;


/**
 发送post请求， 并返回当前task

 @param URLString 请求的网址字符串
 @param parameters 请求的参数
 @param success 请求成功的回调
 @param failure 请求失败的回调
 @return task
 */
- (NSURLSessionDataTask *)task_postWithURLString:(NSString *)URLString
                        parameters:(id)parameters
                           success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
                           failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure;


/**
 设置Header
 
 @param headerString header数据
 @param fieldString header数据对应的value
 @return AFHTTPSessionManager
 */
- (instancetype)addHeader:(NSString *)headerString
                 forField:(NSString *)fieldString;


@end
